|
condition - the next expression to test if the previous branches failed Then (optional) - readability only; Else If always opens a block |
|
The two-word spelling of ElseIf. Blitz3D+ accepts both Else If and ElseIf, and they compile to exactly the same thing. Which you use is purely a matter of taste - the spaced version reads a little more like English, the joined one is a little more compact. Pick one and stay with it within a project. Everything on the ElseIf page applies here: branches are tested in order, only the first true one runs, an optional Then may follow the condition, and a final Else catches the rest before EndIf closes the block. The same holds for the block terminator, where EndIf and End If are likewise interchangeable. See also: ElseIf, If, Else, EndIf, Then. |
; Else If Example
; ---------------
; The pilot's status after the last battle
hull=65
; Else If checks a further condition when the ones above it failed
; (it may also be written as the single word ElseIf)
If hull>=75 Then
Print "Hull at "+hull+"% - all systems go!"
Else If hull>=40 Then
Print "Hull at "+hull+"% - fly carefully out there."
Else If hull>=10 Then
Print "Hull at "+hull+"% - return to base immediately!"
Else
Print "Hull at "+hull+"% - eject! Eject!"
End If
Print ""
Print "Press any key to close the example"
WaitKey
End